<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!-- 官网提供的 axios 在线地址 -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="util.js"></script>
</head>
<body>
<div id="app">
<table border="1">
    <tr>
        <td>ID</td>
        <td><input type="text" name="id" v-model="pojo.id" readonly></td>
    </tr>
    <tr>
        <td>姓名</td>
        <td><input type="text" name="name" v-model="pojo.name" ></td>
    </tr>
    <tr>
        <td>年龄</td>
        <td><input type="number" name="age" v-model="pojo.age" ></td>
    </tr>
    <tr>
        <td>性别</td>
        <td><input type="text" name="sex" v-model="pojo.sex" ></td>
    </tr>
    <tr>
        <td>手机号</td>
        <td><input type="number" name="sjh" v-model="pojo.sjh" ></td>
    </tr>
    <tr>
        <td>地址</td>
        <td><input type="dz" name="dz" v-model="pojo.dz" ></td>
    </tr>
    <tr align="center">
        <td colspan="2"><button type="button" @click="add()">保存</button></td>

    </tr>
</table>
</div>
<script>
    new Vue({
        el:"#app",
        data:{

            pojo:{}

        },
        created() {
            this.hx()
        },
        methods: {
            hx(){
                var id=getQueryString("id")
                axios.get("/user/hx?id="+id).then(
                    res=>{
                        this.pojo=res.data
                    }
                )
            },
            add(){
                axios.post("/user/add",this.pojo).then(
                    res=>{
                       alert("保存成功")
                        location.href="ulist.html"
                    }
                )
            }

        }
    })
</script>
</body>
</html>